Skip to content

Optimize financial action operations - #719

Merged
fatemeh-i merged 2 commits into
devfrom
chore/fi-action-store-optimization
Aug 17, 2026
Merged

Optimize financial action operations#719
fatemeh-i merged 2 commits into
devfrom
chore/fi-action-store-optimization

Conversation

@fatemeh-i

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR focuses on reducing load and improving reliability for high-volume financial operations by adding idempotency to wallet transfers, optimizing accountant-side “unprocessed” checks, and improving archiving/retry behavior.

Changes:

  • Add transfer idempotency via transferRef lookups and duplicate-key recovery to avoid double-applying balance changes.
  • Optimize accountant unprocessed lookups (COUNT → EXISTS), add targeted partial indexes, and tighten archive candidate selection.
  • Improve retry scheduling backoff and archive job batching; extend unit tests to cover the new behaviors.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
wallet/wallet-ports/wallet-persister-postgres/src/main/kotlin/co/nilin/opex/wallet/ports/postgres/impl/TransactionManagerImpl.kt Adds findByTransferRef lookup to support idempotent transfer handling.
wallet/wallet-ports/wallet-persister-postgres/src/main/kotlin/co/nilin/opex/wallet/ports/postgres/dao/TransactionRepository.kt Adds query to fetch transaction id by transfer_ref.
wallet/wallet-core/src/test/kotlin/co/nilin/opex/wallet/core/service/TransferManagerImplTest.kt Adds test to ensure idempotent transfer returns success without side effects.
wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/spi/TransactionManager.kt Extends SPI with findByTransferRef.
wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/service/TransferManagerImpl.kt Implements idempotency flow + duplicate-key recovery and adds helper to build idempotent results.
wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/exc/ConcurrentBalanceChangException.kt Changes exception to unchecked (RuntimeException).
wallet/wallet-app/pom.xml Adds HikariCP dependency in test scope.
accountant/accountant-ports/accountant-persister-postgres/src/test/kotlin/co/nilin/opex/accountant/ports/postgres/FAPersisterImplTest.kt Adds test verifying retry scheduling uses backoff delay.
accountant/accountant-ports/accountant-persister-postgres/src/main/resources/schema.sql Adds partial indexes for unprocessed lookup and archive candidates.
accountant/accountant-ports/accountant-persister-postgres/src/main/kotlin/co/nilin/opex/accountant/ports/postgres/impl/FinancialActionPersisterImpl.kt Fixes retry scheduling to apply backoff starting from the first retry.
accountant/accountant-ports/accountant-persister-postgres/src/main/kotlin/co/nilin/opex/accountant/ports/postgres/impl/FinancialActionLoaderImpl.kt Replaces COUNT-based unprocessed query with EXISTS-based check (returns 1/0).
accountant/accountant-ports/accountant-persister-postgres/src/main/kotlin/co/nilin/opex/accountant/ports/postgres/dao/FinancialActionRepository.kt Adds EXISTS query and tightens archive candidate selection to exclude parents with unprocessed children.
accountant/accountant-app/src/main/kotlin/co/nilin/opex/accountant/app/scheduler/FinancialActionsArchiveJob.kt Archives in multiple batches per run with a configurable cap.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@fatemeh-i
fatemeh-i merged commit 9473b0a into dev Aug 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants